import ajax from "@/utils/ajax";
import API from '@/api/index'
import axios from 'axios'
import * as echarts from 'echarts';
let RefreshList = null
export default {
  props: {
    viewId: {
      type: Number,
      default: () => ''
    }
  },
  data() {
    return {
      screenshow: true,
      fictitiousshow: false,
      type: 1,
      listtype: 1,
      usertype: 1,

      Stationprodinfo: false,
      //历史排名
      historyelectricityconsumptiondata: [],
      historytemperatureRankdata: [],
      historytimeRankdata: [],
      historypowerrankdata: [],
      statisticsdata: {
      },
      sqvtype: 'get7_day_sqv',
      getday: [{
          value: 'get7_day_sqv',
          label: '近7天'
        },
        {
          value: 'get4_week_sqv',
          label: '近4周'
        },
        {
          value: 'get12_month_sqv',
          label: '近12月'
        },
      ],
      chargedata: [],
      chargedatasetdata: [],
      AllChargingPointInformationdata: [],
      Chargingpointtype: 1,
      ChargingPointInformationdata: [

      ],
      ChargingPointInformationshow: false,
      ChargingPointlocation: {
        x: 0,
        y: 0,
      },
      ChargingPointinfoshow: false,
      ChargingPointinfocilckshow: false,
      ChargingPointinfodata: {},
      ChargingDetailsworkstatedata: {},
      ChargingUserGendata: [],
      ChargingUserGenvidedata: [],
      ChargingUserGenvidedatashow: false,
      Charginghistorydata: [],
      Charginghistoryvidedata: [],
      Charginghistorydatashow: false,
      ChargingDetailsrowshow: false,
      currentsotr: 'default',
      chargingDetailstype: 1,
      organId: null,
      poptitle: '',
      probeId: null,
      userId: null,
      ChargingDetailsworkstatetotldata: [{
        maxSt: 0,
        minSt: 0,
        avgSt: 0,
        maxSp: 0,
        minSp: 0,
        avgSp: 0,
        maxSv: 0,
        minSv: 0,
        avgSv: 0,
        maxSi: 0,
        minSi: 0,
        avgSi: 0,
      }],
      loginusrid: this.$store.getters.user.id,
      organListdata: [],
      startColor: '',
      endColor: '',
      step: 30,
      colorArr: [],
      organIdtitle: '',
      todaykwh: 0,
      todaytime: 0,
      todaynow: 0,
      datetypeshow: false,
      Sqvdata:{},
      statetab:3,
      moveuptype:0
    }
  },
  created() {

  },


  mounted() {
    this.getOrganListdata()
    this.gethiddendangerechaer()
  },
  beforeDestroy() {
    //清理定时器
    clearInterval(RefreshList);
  },

  computed: {
    //

    daytitle() {
      switch (this.usertype) {
        case 2:
          return "日期";
        case 3:
          return "周序号";
        case 4:
          return "月份";
        case 5:
          return "年份";
        default:
          return ""
      }
    },
    //区域编码
    batteryNameCode() {
      return function (index) {
        let Code = index.split("-")
        return Code.slice(-1)[0].replace(/[^0-9]/ig, "") > 9 ? Code.slice(-1)[0].replace(/[^0-9]/ig, "") : "0" + Code.slice(-1)[0].replace(/[^1-9]/ig, "")
      }
    },
    ChargingPointlocationy() {
      return this.ChargingPointlocation.y - 150 + 'px'
    },
    ChargingPointlocationx() {
      return this.ChargingPointlocation.x + 30 + 'px'
    },

    prodicon() {
      return function (id) {
        switch (id) {
          case 1:
            return `<svg t="1647829296299" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="52660" width="15" height="15"><path d="M906.113772 31.232H117.830695C64.228234 31.232 19.684234 76.091077 19.684234 131.111385v793.993846C19.684234 980.204308 64.188849 1024 117.830695 1024h788.283077C960.779618 1024 1004.299618 979.140923 1004.299618 925.144615V131.150769A98.185846 98.185846 0 0 0 906.113772 31.192615zM325.308849 240.167385c0-27.490462 22.291692-49.939692 49.624616-49.939693 7.089231 0 14.178462 1.024 19.219692 4.096v-24.457846h29.341538v138.633846h-29.341538V283.963077a43.598769 43.598769 0 0 1-19.259077 4.096A47.497846 47.497846 0 0 1 325.308849 240.167385zM413.333465 920.024615L348.545772 787.534769l35.446154-17.329231 64.748308 132.489847-35.446154 17.32923zM531.684234 676.430769h-39.463385v-109.095384H531.684234v109.095384z m74.870154 247.689846l-35.446154-17.32923 63.803077-131.505231 35.406769 17.329231-63.763692 131.50523zM650.113772 289.083077c-7.089231 0-14.178462-1.024-19.219692-4.096v24.457846h-29.341538V169.865846h29.341538v24.418462c6.065231-3.032615 13.154462-4.056615 19.219692-4.056616 27.332923 0 49.585231 22.449231 49.585231 49.939693 0 27.529846-22.252308 48.955077-49.624615 48.955077z" fill="#ffffff" p-id="52661"></path></svg>`;
          case 2:
            return `<svg t="1649667694554" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="58710" width="15" height="15"><path d="M864.217 116.242c0.003-36.548-13.256-50.507-50.315-51.464-20.846-0.538-41.717-0.097-63.586-0.097l-541.188 0.029c-40.358 0.657-53.903 13.654-53.944 53.297-0.27 262.793-0.365 525.585-0.345 788.378 0.003 36.298 15.963 51.559 53.686 51.59 162.799 0.132 433.915 0.072 596.714 0.022 46.4-0.015 58.996-12.596 58.993-58.317-0.02-261.146-0.039-522.292-0.015-783.438z m-623.98 58.3c0.092-31.892 15.482-45.018 48.35-45.066 111.878-0.164 332.074-0.188 443.952 0.035 31.71 0.063 47.718 14.92 47.883 46.17 0.549 103.37 0.615 206.747 0.102 310.117-0.159 31.963-15.04 46.01-47.647 46.32-56.77 0.54-113.549 0.15-170.324 0.15v-0.357c-55.09 0-218.499 0.217-273.589-0.077-35.18-0.189-46.787-9.878-47.243-44.747-1.359-104.172-1.786-208.365-1.485-312.546z m548.472 434.11c0 6.454-5.281 11.736-11.736 11.736H250.45c-6.455 0-11.736-5.282-11.736-11.737s5.281-11.736 11.736-11.736h526.52c6.457 0 11.738 5.281 11.738 11.736z m-207.433-87.14c29.455 1.194 58.983 0.582 90.567 0.582l18.294-168.505H548.44c6.16 53.285 11.713 104.465 18.552 155.473 0.656 4.894 9.173 12.243 14.284 12.45z m5.987-106.053c25.45 1.108 50.985 0.297 78.111 0.297-2.196 26.71-4.25 49.416-5.865 72.154-1.044 14.695-8.35 21.068-23.102 19.955-17.398-1.313-34.845-1.967-52.182-2.901-4.373-25.424-8.45-47.847-12.006-70.352-1.779-11.255-0.774-19.841 15.044-19.153z m-197.367-90.798h19.16l10.674-56.38c1.258-6.652 10.987-9.854 10.987-22.17v-49.539h-62.441v49.538c0 10.308 9.488 15.418 10.947 22.17 1.458 6.752 10.673 56.381 10.673 56.381z m220.077 0h19.16l10.674-56.38c1.259-6.652 10.987-9.854 10.987-22.17v-49.539h-62.441v49.538c0 10.308 9.488 15.418 10.947 22.17 1.459 6.752 10.673 56.381 10.673 56.381z" fill="#ffffff" p-id="58711"></path></svg>`
          case 3:
            return `<svg t="1650001025572" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3383" width="15" height="15"><path d="M943.616 271.36c-86.528-152.576-247.808-245.76-427.008-245.76-89.6 0-173.056 22.016-248.32 66.56-152.576 86.528-245.76 247.808-245.76 427.008 0 88.064 21.504 171.52 65.024 246.784 88.064 152.576 249.344 245.76 428.544 245.76 89.6 0 173.056-21.504 248.32-65.024 75.264-45.056 135.68-104.96 179.2-180.224 45.056-75.264 66.56-158.72 66.56-246.784 0-89.6-22.016-173.056-66.56-248.32zM306.688 236.544c17.92-34.304 44.544-57.344 80.384-69.12 35.84-12.8 70.144-10.24 102.4 9.216 92.16 53.76 117.76 138.24 76.8 251.904-16.896-8.704-33.28-12.8-50.176-12.8-18.944 0-35.84 5.12-52.224 13.824-18.944-17.92-38.4-30.72-57.344-38.4-88.064-36.864-131.584-92.16-99.84-154.624z m152.064 454.144c8.704 97.28-18.944 161.28-92.16 161.28-38.4 0-71.68-12.8-99.84-39.424-26.624-26.624-39.424-58.88-36.864-95.744 3.584-134.144 108.544-172.544 184.32-184.32 4.608 35.328 24.064 60.928 55.808 77.824-8.704 30.72-12.8 57.344-11.264 80.384z m98.304-131.584c-21.504 21.504-59.904 21.504-81.92 0-21.504-21.504-21.504-58.88 0-80.384 21.504-21.504 59.904-21.504 81.92 0 21.504 21.504 21.504 58.88 0 80.384z m333.824 27.136c-7.68 36.864-28.16 65.024-59.904 81.408-93.184 51.2-179.2 29.184-254.464-65.024 29.184-20.48 43.52-48.64 43.52-84.48v-1.024c29.184-7.68 52.224-17.92 69.12-32.256 72.704-51.2 145.92-70.144 185.344-3.584 18.944 31.744 25.6 67.584 16.384 104.96z" p-id="3384" fill="#ffffff"></path></svg>`
          case 4:
            return `<svg t="1650001093172" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4552" width="15" height="15"><path d="M867.481215 707.803133c-132.713087-59.401017-210.081414-100.644161-278.384417-137.123246A107.640523 107.640523 0 0 0 603.661208 517.240751a108.348326 108.348326 0 0 0-33.702318-78.484478c11.270404-8.656977 22.159683-17.014498 31.306677-23.874744 0 0 179.536987-119.155935 266.215648-79.872862 0 0 89.428204 45.816641 106.497148 133.148659 41.515376 167.47711-48.076167 220.780131-106.497148 239.645807zM494.768419 408.347961c-32.286712 0-60.979962 14.319402-80.934566 36.642424-10.154253-13.230474-20.00905-26.0526-27.958224-36.642424 0 0-121.796585-183.593243-81.669592-272.231974 0 0 46.851123-91.44272 136.115987-108.89279 171.233912-42.468188 225.70753 49.137871 245.008777 108.89279-60.816623 135.925425-103.039802 215.090483-140.390029 285.026877A107.640523 107.640523 0 0 0 494.768419 408.347961z m-108.89279 108.89279a108.348326 108.348326 0 0 0 33.783988 78.566148c-11.107065 8.520861-21.833004 16.76949-30.816659 23.493619 0 0-171.778376 113.983528-254.673012 76.415515 0 0-85.535286-43.829348-101.869205-127.350117-39.718645-160.23574 45.97998-211.197566 101.869205-229.246546 125.199485 56.02534 198.865457 95.172298 263.547774 129.691313A107.858308 107.858308 0 0 0 385.875629 517.240751z m54.446395 0a54.446395 54.446395 0 1 1 108.865566-0.027223A54.446395 54.446395 0 0 1 440.322024 517.240751z m54.446395 108.892789a108.593334 108.593334 0 0 0 76.524408-31.497239c8.548084 11.134288 16.796713 21.914674 23.575289 30.925552 0 0 116.515285 175.64407 78.130576 260.417107 0 0-44.836606 87.468133-130.208553 104.155953-163.801979 40.617011-215.907179-47.014462-234.39173-104.155953 58.448205-130.589678 98.874653-206.324613 134.700381-273.429795A107.749415 107.749415 0 0 0 494.768419 626.13354z" p-id="4553" fill="#ffffff"></path></svg>`
          case 5:
            return `<svg t="1650001332362" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="17022" width="15" height="15"><path d="M684.3904 954.20928H337.71008c54.1184 77.98272 304.05632 76.63616 346.68032 0M512.16384 272.05632c12.63616 0 23.00928-7.40352 23.00928-13.9776a7.3472 7.3472 0 0 0-0.96768-3.54304l-21.39136-119.06048-22.36416 119.23456a7.31136 7.31136 0 0 0-0.96768 3.53792c-0.32768 6.5792 10.04544 13.824 22.6816 13.824m77.22496 479.03232c-51.29728 38.9632-106.13248 36.864-153.91232-5.81632-54.656-49.01376-46.54592-108.25216-16.75264-167.66464 26.9824-53.94944 53.95456-107.89888 84.8128-169.78432 37.1968 58.17856 79.872 115.3024 112.128 177.88416 29.61408 57.6512 33.66912 119.8848-26.27584 165.376M517.04832 117.9392c45.01504 1.56672 83.49696 40.96 83.24096 85.1968a85.8624 85.8624 0 0 1-88.98048 84.14208c-46.08-1.6896-83.50208-39.53152-83.36896-84.40832 0-46.70464 41.8816-86.49728 89.088-84.93056m316.86144 3.28192c0.22528-40.96-15.2576-66.31424-51.50208-78.5408-132.608-44.65152-403.15904-45.33248-535.7824 0.11264-35.99872 12.3392-53.0688 36.56704-52.27008 77.9776 2.3552 119.296 0.78848 238.5408 0.78848 357.81632 0 120.832 1.56672 241.79712-0.90112 362.63936-0.77824 39.04512 15.26272 58.45504 49.59744 65.9712 134.20032 29.39904 406.07744 29.95712 540.27264 0.11264 34.11456-7.74144 50.26816-26.14272 49.93536-65.536q-2.85696-360.17664-0.11264-720.56832" fill="#ffffff" p-id="17023"></path></svg>`
          case 6:
            return `<svg t="1650001768838" class="icon" viewBox="0 0 1547 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="43098" width="15" height="15"><path d="M1410.844 887.467v-819.2c0-36.41-29.582-68.267-68.266-68.267H204.8c-36.409 0-68.267 29.582-68.267 68.267v819.2H0v91.022h4.551C13.653 1005.796 38.684 1024 68.267 1024H1479.11c29.582 0 54.613-18.204 63.716-45.511h4.55v-91.022h-136.533zM250.311 113.777h1046.756v682.667H250.31V113.778z m637.156 796.445H659.91v-45.51h227.556v45.51z" p-id="43099" fill="#ffffff"></path></svg>`
          case 7:
            return `<svg t="1650001826416" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="45130" width="15" height="15"><path d="M924 1024H100A100 100 0 0 1 0 924V340a100 100 0 0 1 100-100h824a100 100 0 0 1 100 100v584a100 100 0 0 1-100 100zM100 320a20 20 0 0 0-20 20v584a20 20 0 0 0 20 20h824a20 20 0 0 0 20-20V340a20 20 0 0 0-20-20z" fill="#ffffff" p-id="45131"></path><path d="M747 925H147a46 46 0 0 1-46-46V385a46 46 0 0 1 46-46h600a46 46 0 0 1 46 46v494a46 46 0 0 1-46 46z m-566-80h532V419H181zM869 554a40 40 0 0 1-40-40V404a40 40 0 0 1 80 0v110a40 40 0 0 1-40 40zM887 675h-36a40 40 0 0 1 0-80h36a40 40 0 0 1 0 80zM887 787h-36a40 40 0 0 1 0-80h36a40 40 0 0 1 0 80zM887 898h-36a40 40 0 0 1 0-80h36a40 40 0 0 1 0 80zM432 317h-1a40 40 0 0 1-30-15L278 150a40 40 0 1 1 62-50l93 115L609 14a40.028 40.028 0 1 1 60 53L462 303a40 40 0 0 1-30 14z" fill="#ffffff" p-id="45132"></path></svg>`
          case 8:
            return `<svg t="1650001894055" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="49009" width="15" height="15"><path d="M512 56.888889C260.266667 56.888889 56.888889 260.266667 56.888889 512s203.377778 455.111111 455.111111 455.111111 455.111111-203.377778 455.111111-455.111111S763.733333 56.888889 512 56.888889z m-85.333333 701.155555c-14.222222 8.533333-31.288889 2.844444-38.4-9.955555l-85.333334-147.911111c-8.533333-14.222222-2.844444-31.288889 9.955556-38.4 14.222222-8.533333 31.288889-2.844444 38.4 9.955555l85.333333 147.911111c8.533333 14.222222 4.266667 31.288889-9.955555 38.4z m113.777777-297.244444c0 15.644444-12.8 28.444444-28.444444 28.444444s-28.444444-12.8-28.444444-28.444444v-170.666667c0-15.644444 12.8-28.444444 28.444444-28.444444s28.444444 12.8 28.444444 28.444444v170.666667z m180.622223 139.377778l-85.333334 147.911111c-8.533333 14.222222-25.6 18.488889-38.4 9.955555-14.222222-8.533333-18.488889-25.6-9.955555-38.4l85.333333-147.911111c8.533333-14.222222 25.6-18.488889 38.4-9.955555 14.222222 7.111111 18.488889 24.177778 9.955556 38.4z" fill="#ffffff" p-id="49010"></path></svg>`
          case 9:
            return `<svg t="1650002111409" class="icon" viewBox="0 0 1152 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="55583" width="15" height="15"><path d="M1050.24 807.168H638.08v112.128H512v-112.128H101.76C46.72 808.128 1.216 770.304 0 722.56V171.904c1.216-47.68 46.72-85.568 101.76-84.544h948.48c55.04-1.024 100.544 36.864 101.76 84.544v550.656c-1.216 47.744-46.72 85.568-101.76 84.608zM352 919.296h448a32 32 0 0 1 0 64h-448a32 32 0 0 1 0-64z" p-id="55584" fill="#ffffff"></path></svg>`
          case 10:
            return `<svg t="1650002152530" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="56786" width="15" height="15"><path d="M877.079517 355.448585c-2.658802-69.258901-48.017385-173.262852-154.564538-173.262852h-2.651577c-63.955747 0-101.345149 39.947054-117.276286 61.296945-2.651577-2.651577-7.961956-2.651577-10.620757-5.310379V147.556283c0-16.039512-13.27956-29.319071-29.319072-29.319071H423.898285c-16.046737 0-29.319071 13.27956-29.319071 29.319071v69.266126H170.6474c-7.961956 0-18.698314 5.310379-21.349891 13.272335-5.310379 7.969181-2.658802 18.698314 0 26.667494L234.595922 384.760432c-39.947054 69.266126-63.955747 151.905736-63.955747 245.288929v165.300897c0 53.327764 37.288252 98.577972 87.964439 109.307105h466.453567c50.676187-10.620758 87.964439-55.986566 87.964439-109.307105V630.049361c0-31.970648-2.651577-63.948522-7.961955-93.267593 53.320539-40.048204 77.329232-101.345149 72.018852-181.333183zM442.488224 166.254597h98.686347v50.676187H442.596599v-50.676187h-0.108375zM215.897608 264.832569h122.586665c-26.66027 18.698314-53.327764 42.598631-74.68488 72.026078l-47.901785-72.026078z m550.986129 522.772483H218.10846v-47.569435h548.768052v47.569435z m27.54172-312.113004c-26.66027-87.957214-79.995259-162.642094-146.595358-210.551104 10.627983-13.387935 34.636675-37.281027 74.68488-37.281027h2.658802c79.995259 2.651577 103.996726 93.267593 103.996726 128.005418 2.543202 53.103789-8.077556 93.159218-34.74505 119.826713z m0 0" p-id="56787" fill="#ffffff"></path></svg>`
          case 11:
            return `<svg data-v-d7ba0f5c="" t="1649667694554" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="58710" width="15" height="15" class="icon"><path data-v-d7ba0f5c="" d="M864.217 116.242c0.003-36.548-13.256-50.507-50.315-51.464-20.846-0.538-41.717-0.097-63.586-0.097l-541.188 0.029c-40.358 0.657-53.903 13.654-53.944 53.297-0.27 262.793-0.365 525.585-0.345 788.378 0.003 36.298 15.963 51.559 53.686 51.59 162.799 0.132 433.915 0.072 596.714 0.022 46.4-0.015 58.996-12.596 58.993-58.317-0.02-261.146-0.039-522.292-0.015-783.438z m-623.98 58.3c0.092-31.892 15.482-45.018 48.35-45.066 111.878-0.164 332.074-0.188 443.952 0.035 31.71 0.063 47.718 14.92 47.883 46.17 0.549 103.37 0.615 206.747 0.102 310.117-0.159 31.963-15.04 46.01-47.647 46.32-56.77 0.54-113.549 0.15-170.324 0.15v-0.357c-55.09 0-218.499 0.217-273.589-0.077-35.18-0.189-46.787-9.878-47.243-44.747-1.359-104.172-1.786-208.365-1.485-312.546z m548.472 434.11c0 6.454-5.281 11.736-11.736 11.736H250.45c-6.455 0-11.736-5.282-11.736-11.737s5.281-11.736 11.736-11.736h526.52c6.457 0 11.738 5.281 11.738 11.736z m-207.433-87.14c29.455 1.194 58.983 0.582 90.567 0.582l18.294-168.505H548.44c6.16 53.285 11.713 104.465 18.552 155.473 0.656 4.894 9.173 12.243 14.284 12.45z m5.987-106.053c25.45 1.108 50.985 0.297 78.111 0.297-2.196 26.71-4.25 49.416-5.865 72.154-1.044 14.695-8.35 21.068-23.102 19.955-17.398-1.313-34.845-1.967-52.182-2.901-4.373-25.424-8.45-47.847-12.006-70.352-1.779-11.255-0.774-19.841 15.044-19.153z m-197.367-90.798h19.16l10.674-56.38c1.258-6.652 10.987-9.854 10.987-22.17v-49.539h-62.441v49.538c0 10.308 9.488 15.418 10.947 22.17 1.458 6.752 10.673 56.381 10.673 56.381z m220.077 0h19.16l10.674-56.38c1.259-6.652 10.987-9.854 10.987-22.17v-49.539h-62.441v49.538c0 10.308 9.488 15.418 10.947 22.17 1.459 6.752 10.673 56.381 10.673 56.381z" fill="#ffffff" p-id="58711"></path></svg>`
          case 12:
            return `<svg t="1650002216958" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="58000" width="15" height="15"><path d="M348.680569 743.428571c0-23.657143 19.2-42.857143 42.857143-42.857142H693.823427v-643.428572c0-31.542857-22.971429-57.142857-51.2-57.142857H156.451998C128.109141 0 105.251998 25.6 105.251998 57.142857v909.714286c0 31.542857 22.857143 57.142857 51.2 57.142857h486.171429c28.228571 0 51.2-25.6 51.2-57.142857v-180.571429H391.537712c-23.657143 0-42.857143-19.2-42.857143-42.857143z m67.428572-129.714285v24c0 9.485714-7.657143 17.142857-17.142857 17.142857s-17.142857-7.657143-17.142857-17.142857v-24c-10.285714-5.942857-17.142857-17.028571-17.142858-29.714286 0-18.971429 15.314286-34.285714 34.285715-34.285714s34.285714 15.314286 34.285714 34.285714c0 12.685714-6.857143 23.771429-17.142857 29.714286z m58.285714-493.714286h97.142857v97.142857h-97.142857v-97.142857z m0 125.714286h97.142857v97.142857h-97.142857v-97.142857z m0 125.714285h97.142857v97.142858h-97.142857v-97.142858z m-125.714286-251.428571h97.142858v97.142857h-97.142858v-97.142857z m0 125.714286h97.142858v97.142857h-97.142858v-97.142857z m0 125.714285h97.142858v97.142858h-97.142858v-97.142858z m-28.571428 97.142858h-97.142857v-97.142858h97.142857v97.142858z m0-125.714286h-97.142857v-97.142857h97.142857v97.142857z m0-125.714286h-97.142857v-97.142857h97.142857v97.142857z m556.571428 493.714286H394.394855c-18.285714 0-33.142857 14.628571-33.142857 32.571428s14.857143 32.571429 33.142857 32.571429h482.285714c18.285714 0 33.142857-14.628571 33.142858-32.571429 0-18.057143-14.857143-32.571429-33.142858-32.571428z" p-id="58001" fill="#ffffff"></path></svg>`
          case 13:
            return `<svg t="1647829296299" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="52660" width="15" height="15"><path d="M906.113772 31.232H117.830695C64.228234 31.232 19.684234 76.091077 19.684234 131.111385v793.993846C19.684234 980.204308 64.188849 1024 117.830695 1024h788.283077C960.779618 1024 1004.299618 979.140923 1004.299618 925.144615V131.150769A98.185846 98.185846 0 0 0 906.113772 31.192615zM325.308849 240.167385c0-27.490462 22.291692-49.939692 49.624616-49.939693 7.089231 0 14.178462 1.024 19.219692 4.096v-24.457846h29.341538v138.633846h-29.341538V283.963077a43.598769 43.598769 0 0 1-19.259077 4.096A47.497846 47.497846 0 0 1 325.308849 240.167385zM413.333465 920.024615L348.545772 787.534769l35.446154-17.329231 64.748308 132.489847-35.446154 17.32923zM531.684234 676.430769h-39.463385v-109.095384H531.684234v109.095384z m74.870154 247.689846l-35.446154-17.32923 63.803077-131.505231 35.406769 17.329231-63.763692 131.50523zM650.113772 289.083077c-7.089231 0-14.178462-1.024-19.219692-4.096v24.457846h-29.341538V169.865846h29.341538v24.418462c6.065231-3.032615 13.154462-4.056615 19.219692-4.056616 27.332923 0 49.585231 22.449231 49.585231 49.939693 0 27.529846-22.252308 48.955077-49.624615 48.955077z" fill="#ffffff" p-id="52661"></path></svg>`
          case 14:
            return `<svg data-v-d7ba0f5c="" t="1647829296299" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="52660" width="15" height="15" class="icon"><path data-v-d7ba0f5c="" d="M906.113772 31.232H117.830695C64.228234 31.232 19.684234 76.091077 19.684234 131.111385v793.993846C19.684234 980.204308 64.188849 1024 117.830695 1024h788.283077C960.779618 1024 1004.299618 979.140923 1004.299618 925.144615V131.150769A98.185846 98.185846 0 0 0 906.113772 31.192615zM325.308849 240.167385c0-27.490462 22.291692-49.939692 49.624616-49.939693 7.089231 0 14.178462 1.024 19.219692 4.096v-24.457846h29.341538v138.633846h-29.341538V283.963077a43.598769 43.598769 0 0 1-19.259077 4.096A47.497846 47.497846 0 0 1 325.308849 240.167385zM413.333465 920.024615L348.545772 787.534769l35.446154-17.329231 64.748308 132.489847-35.446154 17.32923zM531.684234 676.430769h-39.463385v-109.095384H531.684234v109.095384z m74.870154 247.689846l-35.446154-17.32923 63.803077-131.505231 35.406769 17.329231-63.763692 131.50523zM650.113772 289.083077c-7.089231 0-14.178462-1.024-19.219692-4.096v24.457846h-29.341538V169.865846h29.341538v24.418462c6.065231-3.032615 13.154462-4.056615 19.219692-4.056616 27.332923 0 49.585231 22.449231 49.585231 49.939693 0 27.529846-22.252308 48.955077-49.624615 48.955077z" fill="#ffffff" p-id="52661"></path></svg>`
          case 31:
            return `<svg data-v-d7ba0f5c="" t="1647830189889" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="97598" width="15" height="15" class="icon"><path data-v-d7ba0f5c="" d="M257.905053 68.339936a157.861255 68.339936 0 1 0 315.72251 0 157.861255 68.339936 0 1 0-315.72251 0Z" fill="#ffffff" p-id="97599"></path><path data-v-d7ba0f5c="" d="M489.701326 45.559957h-147.870036c-12.089375 0-21.880769 9.791394-21.880769 21.980681v169.351156c0 18.483755 5.894819 36.467948 16.985072 51.254952 13.188409 17.784369 32.871109 40.66426 53.852669 53.353108v273.159918h50.056005V341.499854c20.981559-12.688848 40.66426-35.568738 53.852669-53.353108 10.990341-14.787004 16.985072-32.771197 16.985071-51.254952V67.440726c-0.099912-12.089375-9.891306-21.880769-21.980681-21.880769z" fill="#ffffff" p-id="97600"></path><path data-v-d7ba0f5c="" d="M96.546872 939.774027l-85.824568-35.069178c-13.887794-5.694995-14.387355-25.077959-0.89921-31.472339l277.855791-131.484437 110.502878 24.078837-250.979412 168.751683c-14.986828 10.091131-33.970143 11.989462-50.655479 5.195434zM487.703083 765.027612h479.678407c12.588936 0 24.078837-7.393502 29.274271-18.883403l24.878134-54.85179c5.595082-12.389111-3.696751-26.376817-17.284808-25.977169l-516.446092 15.586301v84.126061z" fill="#ffffff" p-id="97601"></path><path data-v-d7ba0f5c="" d="M523.271821 722.165284c2.997366-10.990341 4.595961-22.480242 4.595961-34.26988 0-73.935018-61.745731-133.982242-137.778906-133.982242s-137.778905 59.947312-137.778905 133.982242c0 11.88955 1.598595 23.379452 4.595961 34.26988h266.365889z" fill="#ffffff" p-id="97602"></path><path data-v-d7ba0f5c="" d="M21.612732 334.905649l145.572056-30.473217c16.185774-3.397014 32.871109 3.397014 42.063031 17.184897L425.657615 646.232023c7.793151 11.589814 2.098156 27.475851-11.290077 31.572251l-62.744854 19.083227c-7.393502 2.198068-15.386477 0.199824-20.881647-5.295346L11.022041 369.974827c-11.589814-11.689726-5.595082-31.772075 10.590691-35.069178z" fill="#ffffff" p-id="97603"></path><path data-v-d7ba0f5c="" d="M255.607073 715.271344a134.481803 73.235633 0 1 0 268.963606 0 134.481803 73.235633 0 1 0-268.963606 0Z" fill="#ffffff" p-id="97604"></path></svg>`

        }
      }
    },


    //
    getranktitle() {
      return function () {

        switch (this.listtype) {
          case 2:
            return this.getWeekopandend(new Date())
          case 3:
            return new Date().getMonth() + 1 + '月'
          case 4:
            return new Date().getFullYear()
        }
      }
    },

    //获取自然周
    getWeek() {
      return function (time) {
        let today = new Date(time); // 当天日期
        let firstDay = new Date(today.getFullYear(), 0, 1);
        let dayOfWeek = firstDay.getDay();
        let spendDay = 1;
        if (dayOfWeek != 0) {
          spendDay = 7 - dayOfWeek + 1;
        }
        firstDay = new Date(today.getFullYear(), 0, 1 + spendDay);
        let d = Math.ceil((today.valueOf() - firstDay.valueOf()) / 86400000);
        let result = Math.ceil(d / 7);
        return result + 1; // 直接返回第几自然周，如：34
      }
    },
    //周开始时间结束
    getWeekopandend() {
      return function (time) {
        let dayCode = new Date(time).getDay();


        let dayLong = 24 * 60 * 60 * 1000;
        let startDay = getFormatDatezhuanh(new Date(dayCode === 0 ? time - dayLong * 7 : time - dayLong * (dayCode - 1)))
        let endDay = getFormatDatezhuanh(new Date(dayCode === 0 ? time : time.getTime() + dayLong * (7 - dayCode)))

        return startDay.slice(5, 10) + ` ` + endDay.slice(5, 10)
      }
    },
    //区域记录序号
    ChargingDetailsHistorytitle() {
      return function (row) {
        switch (this.usertype) {
          case 2:

            return row.day ? row.day.slice(5, 10) : ''
          case 3:
            return row.weekStartDay ? '第' + this.getWeek(row.weekStartDay) + '周' : ''
          case 4:
            return row.monthStartDay ? new Date(row.monthStartDay).getMonth() + 1 + '月' : ''
          case 5:
            return row.yearStartDay ? row.yearStartDay.slice(0, 4) : ''
          case 6:
            return '合计'
        }
      }
    },
    numbac() {
      return function (number) {
        let numer = Math.floor(number)
        if (String(numer).length < 4) {
          numer = (Array(4).join(0) + numer).slice(-4)
        }
        let attr = numer.split('')
        let html = ''
        for (let item of attr) {
          html += `<font>${item}</font>`
        }

        return html
      }
    },
    numbac2() {
      return function (number) {
        let numer = Math.floor(number)
        if (String(numer).length < 4) {
          numer = (Array(4).join(0) + numer).slice(-4)
        }

        return numer
      }
    },
    //时间转换
    calctime() {
      return function (item) {
        if (item > 1) {
          let time = item / 60
          if (time < 60) {
            return "00:" + (time % 60).toFixed(0) + ""
          } else {
            if (Math.floor(time / 60) > 1000) {
              return Math.floor(time / 60) + ":00"
            } else {
              return `${Math.floor(time / 60) < 10?'0':''}` + Math.floor(time / 60) + ":" + (time % 60).toFixed(0) + ""
            }

          }
        } else {
          return '-'
        }
      }
    },
    //时间转换
    calctimehtml() {
      return function (item) {
        let time = item / 60
        if (time < 60) {
          return `<font>${(time % 60).toFixed(0)}</font>` + "分"
        } else {
          return `<font>${Math.floor(time / 60)}</font>:<font>${(time % 60).toFixed(0)}</font>`
        }
      }
    },
    formatNumber() {
      return function (number) {
        if (number >= 100) {
          number = number.toFixed(0)
        } else if (number >= 10) {
          number = number.toFixed(1)
        } else if (number > 0) {
          number = number.toFixed(2)
        } else if (number === 0) {
          number = number.toFixed(2)
        } else {
          number = number.toFixed(2)
        }
        return number
      }
    },
    getFormatDate() {
      return function (nowDate) {
        let date = nowDate == null ? new Date() : new Date(nowDate * 1000)
        let month = date.getMonth() + 1
        let strDate = date.getDate()
        let hours = date.getHours()
        let minutes = date.getMinutes()
        let seconds = date.getSeconds()
        if (month >= 1 && month <= 9) {
          month = '0' + month
        }
        if (strDate < 10) {
          strDate = '0' + strDate
        }
        if (hours < 10) {
          hours = '0' + hours
        }
        if (minutes < 10) {
          minutes = '0' + minutes
        }
        if (seconds < 10) {
          seconds = '0' + seconds
        }
        let currentDate = date.getFullYear() + '-' + month + '-' + strDate + ' ' + hours + ':' + minutes + ':' + seconds
        // console.log(currentDate)
        return currentDate
      }
    },
    //颜色计算2
    colorcacl2() {
      return function (row) {
        let nowvalue
        switch (this.type) {
          case 1:

            nowvalue = row.kWh

            break;
          case 2:

            nowvalue = row.temperature

            break;
          case 3:


            nowvalue = row.Usagetime

            break;
          case 4:

            nowvalue = row.powerFactor

            break;
        }
        return this.colorArr[this.chargedatasetdata.findIndex((value) => value == nowvalue)]
      }
    },

  },
  methods: {

    getOrganListdata() {

      let self = this
      self.getViewAreaListfun()
      self.getViewSqvInfo()
      self.getViewBottomData()
      self.changerBatteryListfun(1)
      clearInterval(RefreshList)
      RefreshList = setInterval(() => {
        self.getViewAreaListfun()
        self.getViewSqvInfo()
        self.getViewBottomData()
       
      }, 60000)
    },
    //获取视图底部统计数据
    getViewBottomData() {
      let self = this
      ajax.get({
        url: this.$API.getViewBottomData + self.viewId,
        showLoading: true,
        success: (response) => {
          self.statisticsdata = response.data
          self.statisticsdata.powerTotal= self.chargedata.reduce((sum, item) => sum + item.powerFactor, 0)
        },
      });
    },
    //获取用电量统计
    getViewSqvInfo() {
      let self = this
      ajax.get({
        url: this.$API.getViewSqvInfo + self.viewId,
        showLoading: true,
        success: (response) => {
          for(let item in response.data){
            self.Sqvdata =  response.data
          }
        },
      });
    },

    //获取工位列表列表
    getViewAreaListfun() {

      let self = this
      ajax.get({
        url: this.$API.getViewAreaIndexInfo + self.viewId,
        showLoading: true,
        success: (response) => {
          if (response.data != null) {
            //console.log(response.data)
            self.listprocessing(response.data)
          } else {
            self.chargedata = []
          }
        },
      });
    },
    //列表排序
    listprocessing(data, type) {
      let self = this
      self.step = data.length
      //默认列表
      for (let item of data) {
        item.powerFactor = item.areaSpTotal
        // item.type = item.areaExclusive
        item.type = 0
        item.kWh = item.areaSqv ? item.areaSqv : '0'
        item.userName = item.areaName
      }
     
      let chargedataattr = [...data]

      chargedataattr = chargedataattr.sort((n1, n2) => {
        return n2.kWh - n1.kWh;
      });
      chargedataattr.forEach((item, i) => {
        item.ranking = i
      });

      self.chargedata = chargedataattr.sort((n1, n2) => {
        return n1.number - n2.number;
      });

      self.chargedata_sort()


      
      // self.todaykwh = chargedataattr.reduce((sum, item) => sum + item.kWh, 0)
      // self.todaytime = chargedataattr.reduce((sum, item) => sum + item.Usagetime, 0)
    


    },
    async rankdata(dayType, orderByField) { //用电前10


      let data
      let self = this
      await axios({
        url: `${this.$API.getUserViewData}?viewId=${self.viewId}&dayType=${dayType}&orderByField=${orderByField}`,
        method: 'GET'
      }).then((res) => {
        data = res.data.data
      })
      return data
    },
    //列表数据切换
    changerBatteryListfun(type) {
      let self = this
      self.listtype = type
      self.datetypeshow = false
      let dayType


      switch (type) {
        case 1:
          dayType = 'DAY'
          break;
        case 2:
          dayType = 'WEEK'
          break;
        case 3:
          dayType = 'MONTH'
          break;
        case 4:
          dayType = 'YEAR'
          break;
      }
      self.rankdata(dayType, 'f_sqv').then(res => {
        self.historyelectricityconsumptiondata = res
      })
      self.rankdata(dayType, 'f_avg_st').then(res => {
        self.historytemperatureRankdata = res
      })
      self.rankdata(dayType, 'f_avg_sp').then(res => {
        self.historypowerrankdata = res
      })

    },


    //鼠标移入显示
    chargemouseenter(e,type,row) {
      if(row.deviceList.length>0){
      this.ChargingPointinfoshow = true
      this.moveuptype = type
      let rowwidth = this.$refs.maincenter.clientWidth
      this.ChargingPointlocation.x = e.clientX + 400 > rowwidth ? e.clientX - 500 : e.clientX + 50
      this.ChargingPointlocation.y = e.clientY 
      this.ChargingPointinfodata = row
      }
    },
//鼠标点击显示
chargeclick(e,type,row) {
  if(row.deviceList.length>0){
  this.ChargingPointinfocilckshow = true
  this.moveuptype = type
  let rowwidth = this.$refs.maincenter.clientWidth
  this.ChargingPointlocation.x = e.clientX + 400 > rowwidth ? e.clientX - 500 : e.clientX + 50
  this.ChargingPointlocation.y = e.clientY 
  this.ChargingPointinfodata = row
  }
},
    headerRowStyle(obj) {

      if (obj.column.label == "herad") {
        return "heradclass"
      } else if (obj.column.label == "heradleve2") {
        return "heradleve2class"
      }
    },
    sorttypechange(e) {
      this.currentsotr = 'default'
      this.chargedata_sort()


    },
    // chargedata_sort(sort,n) {
    chargedata_sort() {
      // this.currentsotr = this.currentsotr == sort && n != 3 ? 'default' : sort

      let self = this

      let chargedatasort = [...this.chargedata]
      let step
      self.chargedatasetdata = []
      self.step = self.chargedata.length
      switch (this.type) {
        case 1:
          chargedatasort = chargedatasort.sort((n1, n2) => {
            return n2.kWh - n1.kWh;
          });
          for (let item of chargedatasort) {
            self.chargedatasetdata.push(item.kWh)
          }
          self.chargedatasetdata = setdata(self.chargedatasetdata)
          step = self.chargedatasetdata.length

          self.startColor = "#008600"
          self.endColor = "#77c676"
          self.colorArr = gradient(self.startColor, self.endColor, step)

          break;
        case 2:

          chargedatasort = chargedatasort.sort((n1, n2) => {
            return n2.temperature - n1.temperature;
          });
          for (let item of chargedatasort) {
            self.chargedatasetdata.push(item.temperature)
          }
          self.chargedatasetdata = setdata(self.chargedatasetdata)
          step = self.chargedatasetdata.length

          self.startColor = "#910000"
          self.endColor = "#f35050"
          self.colorArr = gradient(self.startColor, self.endColor, step)
          break;
        case 3:
          chargedatasort = chargedatasort.sort((n1, n2) => {
            return n2.Usagetime - n1.Usagetime;
          });
          for (let item of chargedatasort) {
            self.chargedatasetdata.push(item.Usagetime)
          }
          self.chargedatasetdata = setdata(self.chargedatasetdata)
          step = self.chargedatasetdata.length

          self.startColor = "#ac4200"
          self.endColor = "#e17b4a"
          self.colorArr = gradient(self.startColor, self.endColor, step)

          break;
        case 4:
          chargedatasort = chargedatasort.sort((n1, n2) => {
            return n2.powerFactor - n1.powerFactor;
          });
          for (let item of chargedatasort) {
            self.chargedatasetdata.push(item.powerFactor)
          }
          self.chargedatasetdata = setdata(self.chargedatasetdata)
          step = self.chargedatasetdata.length

          self.startColor = "#84006e"
          self.endColor = "#ec58d6"
          self.colorArr = gradient(self.startColor, self.endColor, step)
          break;
      }
      chargedatasort.forEach((item, i) => {
        item.ranking = i
      });
      if (this.currentsotr == 'desc') {
        this.chargedata = chargedatasort.sort((n1, n2) => {
          return n2.ranking - n1.ranking;
        });

      } else if (this.currentsotr == 'asc') {

        this.chargedata = chargedatasort.sort((n1, n2) => {
          return n1.ranking - n2.ranking;
        });

      } else {
        this.chargedata = chargedatasort.sort((n1, n2) => {
          return n1.number - n2.number;
        });
      }
    },
    chargingDetailstype_change(type) {
      this.chargingDetailstype = type
      this.Charginghistorydatashow = false
      this.ChargingUserGenvidedatashow = false
      if (type != 1) {
        this.getChargingDetailsuserData()
      }
    },
    //充电日志(时间+用户id)
    getBatteryLogByTimeAndUserIdfun(row) {
      let self = this
      let currTime
      let endTime
      let startTime
      let urlling
      if (this.chargingDetailstype == 2) {
        urlling = self.$API.getBatteryLogByTimeAndUserId + self.userId
      } else if (this.chargingDetailstype == 3) {
        urlling = self.$API.getBatteryLogByTimeAndProbeId + self.probeId
      }
      let date
      switch (self.usertype) {
        case 1:
          switch (row.type) {
            case '日':
              currTime = row.day.slice(0, 10)
              urlling += `?currTime=${currTime}`
              break;
            case '周':
              startTime = row.weekStartDay.slice(0, 10)
              date = new Date(row.weekStartDay)

              endTime = getFormatDatezhuanh(new Date(date.setDate(date.getDate() + 6))).slice(0, 10)
              urlling += `?startTime=${startTime}&endTime=${endTime}`
              break;
            case '月':
              startTime = row.monthStartDay.slice(0, 10)
              endTime = monthendtime(row.monthStartDay).slice(0, 10)
              urlling += `?startTime=${startTime}&endTime=${endTime}`
              break;
            case '年':
              startTime = row.yearStartDay.slice(0, 4) + "-01-01"
              endTime = row.yearStartDay.slice(0, 4) + "-12-31"
              urlling += `?startTime=${startTime}&endTime=${endTime}`
              break;
          }
          break;
        case 2:
          currTime = row.day.slice(0, 10)
          urlling += `?currTime=${currTime}`
          break
        case 3:
          startTime = row.weekStartDay.slice(0, 10)
          date = new Date(row.weekStartDay)
          endTime = getFormatDatezhuanh(new Date(date.setDate(date.getDate() + 6))).slice(0, 10)
          urlling += `?startTime=${startTime}&endTime=${endTime}`
          break
        case 4:
          startTime = row.monthStartDay.slice(0, 10)
          endTime = monthendtime(row.monthStartDay).slice(0, 10)
          urlling += `?startTime=${startTime}&endTime=${endTime}`
          break;
        case 5:
          startTime = row.yearStartDay.slice(0, 4) + "-01-01"
          endTime = row.yearStartDay.slice(0, 4) + "-12-31"
          urlling += `?startTime=${startTime}&endTime=${endTime}`
          break;
        case 6:
          date = getFormatDatezhuanh(new Date())
          startTime = "2020-01-01"
          endTime = date.slice(0, 4) + "-12-31"
          urlling += `?startTime=${startTime}&endTime=${endTime}`
          break;
      }
      ajax.get({
        url: urlling,
        showLoading: true,
        success: (response) => {
          if (self.chargingDetailstype == 2) {
            self.ChargingUserGenvidedata = response.data
            self.ChargingUserGenvidedatashow = true
            self.Charginghistorydatashow = false
          } else if (self.chargingDetailstype == 3) {
            self.ChargingUserGenvidedata = response.data
            self.ChargingUserGenvidedatashow = false
            self.Charginghistorydatashow = true
          }
        }
      })

    },
    gethiddendangerechaer() {
      let self = this

      ajax.get({
        url: `${this.$API.getSqv}${self.sqvtype}/${self.viewId}`,
        showLoading: true,
        success: (response) => {
          let data ={
            y1:[],
            x:[],
            y:[]
          }
          response.data.forEach(item =>{
           data.y1.push(item.y1)
           data.x.push(item.x)
           data.y.push(item.y)
          })
          console.log(data)
          this.hiddendangerechaer(data)
        }
      })

    },
    hiddendangerechaer(data) {

      let weektext = ['一', '二', '三', '四', '五', '六', '日']
      let xdata = []
      let ydata = []
      let sqvtype = this.sqvtype
      switch (this.sqvtype) {
        case 'get7_day_sqv':
          for (let xtext of data.x) {
            xdata.push(`周` + weektext[parseInt(xtext) - 1])
          }
          break;
        case 'get4_week_sqv':
          for (let xtext of data.x) {
            xdata.push(xtext.slice(5, 10) + `~` + xtext.slice(16, 21) )
          }
          break;
        case 'get12_month_sqv':
          for (let xtext of data.x) {
            xdata.push(xtext + `月`)
          }
          break;
      }
      for (let ytext of data.y) {
        ydata.push(ytext / 1000)
      }
      let myChart = null

      let option = {
        title: {
          text: `${this.getday.filter(data=>data.value ==this.sqvtype)[0].label}区域总用电量(度)`,
          textStyle: {
            fontSize: "0.16rem",
            color: "#e59319",
            fontWeight: "normal"
          },
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          },
          formatter: function (params) {
            let aftiem =""
            let afweektime
            let afkwh = ((data.y1[params[0].dataIndex])/ 1000).toFixed(2)
            let nowkwh =((data.y[params[0].dataIndex])/ 1000).toFixed(2)
            let todatdate 
            let afdata 
            let diff
            switch (sqvtype) {
              case 'get7_day_sqv':
                diff = data.x[6] - data.x[params[0].dataIndex] <0? data.x[6] - data.x[params[0].dataIndex] + 7 :data.x[6] - data.x[params[0].dataIndex]
                todatdate= getFormatDatezhuanh(new Date(new Date().getTime() - (diff * 60 * 60 * 24 * 1000))).slice(0,10)
                afdata = new Date().getTime() - ((7 + diff) * 60 * 60 * 24 * 1000)
              
                // console.log(afdata)
                aftiem = `${getFormatDatezhuanh(new Date(afdata)).slice(0,10)} 上${params[0].axisValue} `
                break;
              case 'get4_week_sqv':
                afweektime = getWeektoday(getWeek(data.x[params[0].dataIndex].slice(0,10)) - 4,data.x[params[0].dataIndex].slice(0,4),86400000)
                aftiem = `${afweektime.slice(5, 10)}~${afweektime.slice(16, 21)}`
                break;
              case 'get12_month_sqv':
                aftiem = `去年${params[0].axisValue}`
                break;
            }
          // console.log(params)
          // console.log()
          let html =`<div style="padding:0.05rem"><span>${params[0].marker}周期对比用电量(度)</span><br/> ${sqvtype=='get7_day_sqv'?todatdate:''} ${params[0].axisValue}：${nowkwh}<br/>${aftiem}：${afkwh}<br/>
          对比上周期${nowkwh<afkwh?'降低':'增加'}：${Math.abs(nowkwh - afkwh)}(${afkwh ==0 ||nowkwh ==0 ?'--%':nowkwh<afkwh?((afkwh/nowkwh) * 100).toFixed(0) + '%':((nowkwh/afkwh) * 100).toFixed(0)+ '%'} )</div>`
          return html
          //  console.log()
          //  console.log(data.y[params[0].dataIndex])
        },
        },
        grid: {
          left: "8%",
          bottom: "12%",
          top: "18%",
          right: "0%"
        },
        xAxis: {
          type: 'category',
          data: xdata,
          nameTextStyle: {
            color: "#fff",
          },
          axisLabel: {
            show: true,
            fontSize: 12,
            textStyle: {
              color: "#fff",
            },
          },
          axisLine: {
            lineStyle: {
              color: "#fff",
            },
          },
        },
        yAxis: {
          type: 'value',
          axisLabel: {
            show: true,
            textStyle: {
              color: "#fff",
            },
          },
          axisLine: {
            lineStyle: {
              color: "#fff",
            },
          },
        },
        series: [{
          data: ydata,
          type: 'bar',
          itemStyle: {
            color: '#409EFF'
          }
        }]
      };

      myChart = echarts.init(document.getElementById("barChart2"));
      myChart.clear()
      myChart.setOption(option);
    },
    //关闭区域
    closeCharg() {
      // this.$prompt('确定关闭区域，请输入12345。', '提示', {
      // const h = this.$createElement;
      // this.$prompt({
      // title: '再次确定',
      // message: h('p', null, [
      //   h('span', null, '确定关闭区域，请输入 '),
      //   h('span', { style: 'color: #f00' }, '12345')
      // ]),
      // showCancelButton: true,

      this.$prompt('', {
        title: '再次确定',
        dangerouslyUseHTMLString: true,
        message: `确定关闭区域，请输入<font style='color:#f00'>12345</font>。`,
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        inputValidator(value) {
          if ((value ?? '') == '') {
            return '输入确定信息不能为空'
          } else if (value != 12345) {
            return '输入确定信息不正确'
          }
        },
        inputErrorMessage: '输入信息不正确'
      }).then(() => {
        this.$message({
          type: 'success',
          message: '关闭成功 '
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '取消关闭'
        });
      });
    },
    getChargingDetailsuserData() {
      let getlink
      let self = this

      if (this.chargingDetailstype == 3) {
        self.Charginghistorydata = []
        switch (this.usertype) {
          case 1:
            getlink = this.$API.getBatteryProbeViews
            break;
          case 2:
            getlink = this.$API.getBatteryProbeDay
            break;
          case 3:
            getlink = this.$API.getBatteryProbeWeek
            break;
          case 4:
            getlink = this.$API.getBatteryProbeMonth
            break;
          case 5:
            getlink = this.$API.getBatteryProbeYear
            break;
          case 6:
            getlink = this.$API.getBatteryProbeTotal
            break;
        }

        ajax.get({
          url: getlink += self.probeId,
          showLoading: true,
          success: (response) => {

            if (this.usertype == 1) {

              response.data.day.type = "当日"
              response.data.week.type = "当周"
              response.data.month.type = "当月"
              response.data.year.type = "当年"
              self.Charginghistorydata.push(response.data.day)
              self.Charginghistorydata.push(response.data.week)
              self.Charginghistorydata.push(response.data.month)
              self.Charginghistorydata.push(response.data.year)
            } else {
              self.Charginghistorydata = response.data
            }
          }
        })
      } else if (this.chargingDetailstype == 2) {
        self.ChargingUserGendata = []
        switch (this.usertype) {
          case 1:
            getlink = this.$API.getBatteryUserViews
            break;
          case 2:
            getlink = this.$API.getBatteryUserDay
            break;
          case 3:
            getlink = this.$API.getBatteryUserWeek
            break;
          case 4:
            getlink = this.$API.getBatteryUserMonth
            break;
          case 5:
            getlink = this.$API.getBatteryUserYear
            break;
          case 6:
            getlink = this.$API.getBatteryUserTotal
            break;
        }

        ajax.get({
          url: getlink += self.userId,
          showLoading: true,
          success: (response) => {

            if (this.usertype == 1) {

              response.data.day.type = "日"
              response.data.week.type = "周"
              response.data.month.type = "月"
              response.data.year.type = "年"
              self.ChargingUserGendata.push(response.data.day)
              self.ChargingUserGendata.push(response.data.week)
              self.ChargingUserGendata.push(response.data.month)
              self.ChargingUserGendata.push(response.data.year)

            } else {
              self.ChargingUserGendata = response.data
            }

          }
        })
      }

    },
  },
  watch: {
    viewId(val, oldVal) {

      this.getOrganListdata()
      this.gethiddendangerechaer()
    },
    usertype(val) {
      this.Charginghistorydatashow = false
      this.ChargingUserGenvidedatashow = false
      this.getChargingDetailsuserData()
    }
  }
}

function getFormatDatezhuanh(nowDate) {
  let date = nowDate
  let month = date.getMonth() + 1
  let strDate = date.getDate()
  let hours = date.getHours()
  let minutes = date.getMinutes()
  let seconds = date.getSeconds()
  if (month >= 1 && month <= 9) {
    month = '0' + month
  }
  if (strDate < 10) {
    strDate = '0' + strDate
  }
  if (hours < 10) {
    hours = '0' + hours
  }
  if (minutes < 10) {
    minutes = '0' + minutes
  }
  if (seconds < 10) {
    seconds = '0' + seconds
  }
  let currentDate = date.getFullYear() + '-' + month + '-' + strDate + ' ' + hours + ':' + minutes + ':' + seconds
  // console.log(currentDate)
  return currentDate
}

function monthendtime(data) {
  let nowDate = new Date(data);
  let cloneNowDate = new Date(data);
  let fullYear = nowDate.getFullYear();
  let month = nowDate.getMonth() + 1; // getMonth 方法返回 0-11，代表1-12月 
  let endOfMonth = new Date(fullYear, month, 0).getDate(); // 获取本月最后一天
  let endDate = getFormatDatezhuanh(new Date(cloneNowDate.setDate(endOfMonth))) //当月最后一天 
  return endDate
}

// rgb to hex
function rgbToHex(r, g, b) {
  let hex = ((r << 16) | (g << 8) | b).toString(16);
  return "#" + new Array(Math.abs(hex.length - 7)).join("0") + hex;
}

// hex to rgb
function hexToRgb(hex) {
  let rgb = [];
  for (let i = 1; i < 7; i += 2) {
    rgb.push(parseInt("0x" + hex.slice(i, i + 2)));
  }
  return rgb;
}

// 计算渐变过渡色
function gradient(startColor, endColor, step) {
  // 将 hex 转换为rgb
  var sColor = hexToRgb(startColor),
    eColor = hexToRgb(endColor);

  // 计算R\G\B每一步的差值
  let rStep = (eColor[0] - sColor[0]) / step
  let gStep = (eColor[1] - sColor[1]) / step;
  let bStep = (eColor[2] - sColor[2]) / step;

  let gradientColorArr = [];
  for (let i = 0; i < step; i++) {
    // 计算每一步的hex值
    gradientColorArr.push(rgbToHex(parseInt(rStep * i + sColor[0]), parseInt(gStep * i + sColor[1]), parseInt(bStep * i + sColor[2])));
  }
  return gradientColorArr;
}

function randomnum(min, max) {
  return Math.floor(Math.random() * (max - min + 1) + min)
}

function setdata(data) {
  return [...new Set(data)]
}
//获取自然周
function getWeek(time) {
    let today = new Date(time); // 当天日期
    let firstDay = new Date(today.getFullYear(), 0, 1);
    let dayOfWeek = firstDay.getDay();
    let spendDay = 1;
    if (dayOfWeek != 0) {
      spendDay = 7 - dayOfWeek + 1;
    }
    firstDay = new Date(today.getFullYear(), 0, 1 + spendDay);
    let d = Math.ceil((today.valueOf() - firstDay.valueOf()) / 86400000);
    let result = Math.ceil(d / 7);
    return result + 1; // 直接返回第几自然周，如：34
  
}
function getWeektoday(datevalue, year,tiem) {

  let week = datevalue - 1
  //获取周开始日期
  const date1 = new Date(year, 0, 4);
  date1.setDate(date1.getDate() - date1.getDay());
  date1.setTime((date1.getTime() + 7 * 86400000 * (week - 1)) + tiem);
  let year1 = date1.getFullYear();
  let month1 = date1.getMonth() + 1;
  if (month1 >= 1 && month1 <= 9) {
    month1 = "0" + month1;
  }
  let dates1 = date1.getDate();
    if (dates1 >= 1 && dates1 <= 9) {
    dates1 = "0" + dates1;
  }
  let startDate = year1 + '-' + month1 + '-' + dates1;

  //获取周结束日期
  const date = new Date(year, 0, 4);
  date.setDate(date.getDate() - date.getDay());
  date.setTime((date.getTime() + (7 * 86400000 * week) - 1)+ tiem);
  let year2 = date.getFullYear();
  let month2 = date.getMonth() + 1;
  if (month2 >= 1 && month2 <= 9) {
    month2 = "0" + month2;
  }
  let dates2 = date.getDate();
    if (dates2 >= 1 && dates2 <= 9) {
    dates2 = "0" + dates2;
  }
  let endDate = year2 + '-' + month2 + '-' + dates2;
  return startDate + '~' + endDate
}